package com.platform.modules.plug.controller;

import com.platform.common.version.ApiVersion;
import com.platform.common.version.VersionEnum;
import com.platform.common.web.domain.AjaxResult;
import com.platform.modules.wallet.domain.WalletRedPacket;
import com.platform.modules.wallet.domain.WalletRedPacketSub;
import com.platform.modules.wallet.domain.WalletTransfer;
import com.platform.modules.wallet.service.WalletRedPacketService;
import com.platform.modules.wallet.service.WalletTransferService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Slf4j
@RequestMapping("/open")
public class OpenController {

    @Resource
    private WalletRedPacketService walletRedPacketService;
    @Resource
    private WalletTransferService walletTransferService;
    /**
     * 查询已接收的红包列表
     */
    @ApiVersion(VersionEnum.V1_0_0)
    @GetMapping("/queryRedPacket/{queryId}")
    public AjaxResult queryRedPacket(@PathVariable String queryId) {

        WalletRedPacket redPacket = walletRedPacketService.getByQueryId(queryId);
        List<WalletRedPacketSub> walletRedPacketSubs = walletRedPacketService.queryByRedRacketId(redPacket.getId());

        return AjaxResult.success(walletRedPacketSubs);
    }

    /**
     * 查询已接收的红包列表
     */
    @ApiVersion(VersionEnum.V1_0_0)
    @GetMapping("/queryTransfer/{queryId}")
    public AjaxResult queryTransfer(@PathVariable String queryId) {

        WalletTransfer transfer = walletTransferService.getByQueryId(queryId);

        return AjaxResult.success(transfer);
    }
}
